<?php

/**
 * Ignus Framework
 *
 * @author Sergey Palyanov <sergey.palyanov@gmail.com>
 * @link http://code.google.com/p/ignus-php/
 * @license http://apache.org/licenses/LICENSE-2.0
 * @package Ignus
 * @subpackage Mock
 * @since 0.1
 */

namespace Ignus\Test\Mock;

/**
 * @package Ignus
 * @subpackage Mock
 * @since 0.1
 */
class Expectation
{
    /**
     * Number of method invokations
     * @var int
     */
    private $times;

    /**
     * Invokator instance
     * @var Ignus\Test\Mock\Invokator
     */
    private $invokator;

    /**
     * @param int $times Number of method invokations
     */
    public function __construct(Invokator $invokator, $times = 1)
    {
        $this->invokator = $invokator;
        $this->times = $times;
    }

    /**
     * Catch invokations of not existed methods
     * @param string $name Method name
     * @param array $arguments Method arguments
     * @return void
     */
    public function __call($name, array $arguments)
    {
        $this->invokator->expects($name, $arguments, $this->times);
    }
}
